go
create database bkavcuongbilly
go
use bkavcuongbilly
go
create table soluongs
(
	soluong int primary key,
	gia varchar(7) not null,
)
go
create table hoadon
(
	hoadonID int identity(1,1) not null,
	hovaten nvarchar(50) not null,
	email nvarchar(50) not null,
	diachi nvarchar(max) not null,
	sodienthoai nvarchar(15) not null,
	tinhthanhpho nvarchar(20) not null,
	thoigian datetime not null,
	tinhtrang nvarchar(15) not null,
	soluong int foreign key(soluong) references soluongs(soluong),
	tongtien varchar(8) not null
)
go
create table logins
(
	account nvarchar(50) primary key,
	password nvarchar(50) not null,
	hovaten nvarchar(50) not null,
	sodienthoai nvarchar(15) not null,
	quen int not null,-- quen 1 admin,quen 2 la nhan vien
	email nvarchar(50) not null,--dung de lay lai password
)
go
create proc giaselect
as
select * from soluongs
go
alter proc donhangInsert
	@hovaten nvarchar(50),
	@email nvarchar(50),
	@diachi nvarchar(max),
	@sodienthoai nvarchar(15),
	@tinhthanhpho nvarchar(20),
	@thoigian datetime,
	@soluong int,
	@tongtien varchar(8)
as
insert into hoadon values(N'"+"'@hovaten+"'",@email,@diachi,@sodienthoai,
	@tinhthanhpho,@thoigian,'dathang',@soluong,@tongtien)



go
insert into soluongs values(1,'250.000');

insert into soluongs values(2,'220.000');
insert into soluongs values(3,'220.000');

insert into soluongs values(4,'210.000');
insert into soluongs values(5,'210.000');
insert into soluongs values(6,'210.000');
insert into soluongs values(7,'210.000');
insert into soluongs values(8,'200.000');
insert into soluongs values(9,'200.000');

insert into soluongs values(10,'200.000');
insert into soluongs values(11,'200.000');
insert into soluongs values(12,'200.000');
insert into soluongs values(13,'200.000');
insert into soluongs values(14,'190.000');
insert into soluongs values(15,'190.000');
insert into soluongs values(16,'190.000');
insert into soluongs values(17,'190.000');
insert into soluongs values(18,'190.000');
insert into soluongs values(19,'190.000');
insert into soluongs values(20,'190.000');

insert into soluongs values(21,'180.000');
insert into soluongs values(22,'180.000');
insert into soluongs values(23,'180.000');
insert into soluongs values(24,'180.000');
insert into soluongs values(25,'180.000');
insert into soluongs values(26,'180.000');
insert into soluongs values(27,'180.000');
insert into soluongs values(28,'180.000');
insert into soluongs values(29,'180.000');
insert into soluongs values(30,'180.000');

--drop database bkavcuongbilly
select * from hoadon